#include <player.h>
#include <stats.h>

player::player( std::vector<stats *> * stats ) {
	this->_constructor_real(stats);
}

player::player() {
	std::vector<stats *> * attrb = new std::vector<stats *>();
	this->_constructor_real(attrb);
}

void player::_constructor_real( std::vector<stats *> * attrb ) {
	this->attrb = attrb;
}

void player::addStat( stats * s ) {
	this->attrb->push_back( s );
}

void player::addStatSet( std::vector<stats *> * s ) {
	free(this->attrb);
	this->attrb = s;
}

stats * player::getStat( std::string name ) {
	for ( unsigned int i = 0; i < this->attrb->size(); ++i )
		if ( this->attrb->at(i)->getName() == name )
			return ( this->attrb->at(i) );

	throw _badbeef; // uh oh. nothing found
}

bool player::runStat( std::string name ) {
	stats * s = this->getStat(name); // this can error out.
	return ( s->processValue() );
}
